home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / array / stringfindsimple.c < prev    next >
C/C++ Source or Header  |  2001-05-12  |  462b  |  35 lines

  1.  
  2. #include "tek/array.h"
  3.  
  4. /* 
  5. **    TEKlib
  6. **    (C) 2001 TEK neoscientists
  7. **    all rights reserved.
  8. */
  9.  
  10. TINT TStringFindSimple(TSTRPTR string, TSTRPTR search, TINT stringlen, TINT searchlen)
  11. {
  12.     TINT pos = -1;
  13.     TINT foundpos = 0, x = 0;
  14.  
  15.     while (x + foundpos < stringlen)
  16.     {
  17.         if (string[x + foundpos] == search[foundpos])
  18.         {
  19.             foundpos++;
  20.             if (foundpos == searchlen)
  21.             {
  22.                 pos = x;
  23.                 break;
  24.             }
  25.         }
  26.         else
  27.         {
  28.             x++;
  29.             foundpos = 0;
  30.         }
  31.     }
  32.     
  33.     return pos;
  34. }
  35.